<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>答辩分组(修改)</title>
    <link rel="stylesheet" type="text/css" href="../css/htmleaf-demo.css">
    <link rel="stylesheet" type="text/css" href="../css/nav.css">
    <link rel="stylesheet" type="text/css" href="../fonts/iconfont.css">

    <link rel="stylesheet" href="../css/bootstrap-theme.css"/>

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap.css"/>
    <script type="text/javascript" src="../js/bootstrap3.0.3.min.js"></script>

    <link rel="stylesheet" type="text/css" href="../layer/theme/default/layer.css">
    <link rel="stylesheet" type="type/css" href="../layer/mobile/need/layer.css">
    <link rel="stylesheet" type="text/css" href="../css/style.css">
    <script type="text/javascript" src="../js/jquery.js"></script>

    <style>
        .formtop{
            margin-top: 40px;
        }
        .formtop1{
            margin-top: 10px;
        }
        .formleft{
            width: 95%;
            float: left;
            margin-left: 0;
        }
        .fromcenter{
            width: 95%;
            float: left;
        }
        .formright{
            width: 95%;
            float: left;
            margin-right: 0;
        }
        .input-df{
            margin:10px ;
        }
    </style>





    <!--//多选框代码-->
    <script>
        function selectSet(s1, s2) {
            s1.attr("multiple", "multiple");
            //使用attr();函数设置select的风格，multiple表示不是下拉风格，是选择列表风格
            s1.width("100%");
            //通过width()函数设置select的宽度
            s1.attr("size", "8");
            //设置select的界面中最大可以同时显示8个项
            s1.css("border", "1px solid black");
            //设置select的css样式：边框线：5px 粗，实线 红色
            s1.css("backgroundColor", "#FFFFFF");
            //设置select的背景色为白色：RGB格式，#FFFFFF为2+2+2看，红色+绿色+蓝色
            s1.css("color", "#000000");
            //设置select的颜色为黑色
            s1.css("font-size", "23px");
            //设置select中的字体大小为25px
            s1.css("font-family", "楷体");
            //设置select中的字体为楷体
            s1.height("200px");
            //设置select的高度为248px
            s2.attr("multiple", "multiple");
            s2.width("100%");
            s2.attr("size", "8");
            s2.css("border", "1px solid black");
            s2.css("backgroundColor", "#FFFFFF");
            s2.css("color", "#000000");
            s2.css("font-size", "23px");
            s2.css("font-family", "楷体");
            s2.height(s1.height());
        }

        $(document).ready(function() {
            var $select = $("#leftselect");
            //通过JQuery的id选择器得到左面的select的JQuery对象
            var $select1 = $("#rightselect");
            //得到右面的select的JQuery对象
            selectSet($select, $select1);

            var s1 = $("#leftselectS");
            var s2 = $("#rightselectS");
            selectSet(s1, s2);
            for(var i = 0; i < 8; i++) {
                var $temp = $("#button" + (i + 1));
                $temp.css("backgroundColor", "#807345"); //按钮颜色
                $temp.css("font-family", "Times New Roman");
                $temp.css("font-size", "23px");
                $temp.css("float", "left");
//                $temp.css("marginTop", $select1.height + "px");
                $temp.width("20%");
                switch(i) {
                    case 0:
                        $temp.text("↓");
                        $temp.click(function() {
                            $("#leftselect :selected").appendTo($select1); //使用id选择器和属性选择器联合找到选中的选项，并加入到右面的select中
                        });
                        break;
                    case 1:
                        $temp.text("↑");
                        $temp.click(function() {
                            $("#rightselect :selected").appendTo($select);
                        });
                        break;
                    case 2:
                        $temp.text("↓↓");
                        $temp.click(function() {
                            $("#leftselect > option").appendTo($select1); //使用id选择器和子项选择器找到左面select中的所有项，并加入到右面的select中
                        });
                        break;
                    case 3:
                        $temp.text("↑↑");
                        $temp.click(function() {
                            $("#rightselect > option").appendTo($select);
                        });
                        break;
                    case 4:
                        $temp.text("↓");
                        $temp.click(function() {
                            $("#leftselectS :selected").appendTo($("#rightselectS")); //使用id选择器和属性选择器联合找到选中的选项，并加入到右面的select中
                        });
                        break;
                    case 5:
                        $temp.text("↑");
                        $temp.click(function() {
                            $("#rightselectS :selected").appendTo($("#leftselectS"));
                        });
                        break;
                    case 6:
                        $temp.text("↓↓");
                        $temp.click(function() {
                            $("#leftselectS > option").appendTo($("#rightselectS")); //使用id选择器和子项选择器找到左面select中的所有项，并加入到右面的select中
                        });
                        break;
                    case 7:
                        $temp.text("↑↑");
                        $temp.click(function() {
                            $("#rightselectS > option").appendTo($("#leftselectS"));
                        });
                        break;
                }
            }

        });
    </script>
    <!--相关操作-->
    <script type="text/javascript">
        function roomChange() {
            var room = document.getElementById("room");
            var roomNum = room.value;
            var $leftselect = $("#leftselect");
            var $rightselect1 = $("#rightselect");
            var $leftselectS = $("#leftselectS")
            var i = 0;
            $.post("a-groupProcess.php", {
                    actionType: "roomChoose",
                    roomId: roomNum
                },
                function(data) {
                    $leftselect.empty();
                    $leftselectS.empty();
                    for(var i = 0; i < data.tId.length; i++) {
                        var $option = $("<option></option>");
                        //创建option标签
                        $option.attr("id", "option" + (i + 1));
                        //设置id为option(i+1)
                        $option.css("backgroundColor", "#FFFFFF");
                        //设置背景色为白色
                        $option.css("color", "#000000");
                        //设置字体颜色为黑色
                        $option.css("font-size", "23px");
                        //设置字体大小为25px
                        $option.css("font-family", "楷体");
                        //设置字体为楷体
                        $option.val(data.tId[i]);
                        //设置要提交的value
                        $option.text(data.tName[i] + "(" + data.tId[i] + ")"); //我的数据在这里
                        //设置文本为选项(i+1)
                        $option.appendTo($leftselect);
                        //将option挂到select下
                    }
                    for(var i = 0; i < data.sId.length; i++) {
                        var $option = $("<option></option>");
                        //创建option标签
                        $option.attr("id", "option" + (i + 1));
                        //设置id为option(i+1)
                        $option.css("backgroundColor", "#FFFFFF");
                        //设置背景色为白色
                        $option.css("color", "#000000");
                        //设置字体颜色为黑色
                        $option.css("font-size", "23px");
                        //设置字体大小为25px
                        $option.css("font-family", "楷体");
                        //设置字体为楷体
                        $option.val(data.sId[i]);
                        //设置要提交的value
                        $option.text(data.sName[i] + "(" + data.sId[i] + ")"); //我的数据在这里
                        //设置文本为选项(i+1)
                        $option.appendTo($("#leftselectS"));
                        //将option挂到select下
                    }

                }, "json");
        }

        function spick() {
            var text = $("#searchTest").val();
            var data = encodeURI(text);
            $.post("a-groupProcess.php", {
                actionType: "spick",
                searchTest: data
            }, function(data) {

                // alert(data.sName);
                $("#leftselectS").empty();
                for(var i = 0; i < data.sId.length; i++) {
                    var $option = $("<option></option>");
                    //创建option标签
                    $option.attr("id", "option" + (i + 1));
                    //设置id为option(i+1)
                    $option.css("backgroundColor", "#FFFFFF");
                    //设置背景色为白色
                    $option.css("color", "#000000");
                    //设置字体颜色为黑色
                    $option.css("font-size", "23px");
                    //设置字体大小为25px
                    $option.css("font-family", "楷体");
                    //设置字体为楷体
                    $option.val(data.sId[i]);
                    //设置要提交的value
                    $option.text(data.sName[i] + "(" + data.sId[i] + ")"); //我的数据在这里
                    //设置文本为选项(i+1)
                    $option.appendTo($("#leftselectS"));
                    //将option挂到select下
                }
            }, "json");
        }

        //检测组长是否存在
        function adCheck() {

            var adName = document.getElementById("groupAdName").value;
            var span = document.getElementById("adNameError");

            $.ajax({
                type: "POST",
                url: "a-groupProcess.php",
                data: "actionType=adNameCheck&adName=" + adName,
                success: function(msg) {

                    if(msg == 1) {
                        span.style.display = "none";

                    } else {
                        span.style.display = "inline";
                    }
                }
            });
        }

        function allPost() { //提交所选的数据

            var s1 = $("#rightselect>option");
            s1.attr("selected", "selected");
            var s2 = $("#rightselectS>option");
            s2.attr("selected", "selected");


        }
    </script>
</head>
<body class="bodycolor">
<nav class="navbar navbar-default navbar-fixed-top" style="clear:
left;">
    <div class="container">
        <div class="navbar-right navfont" id="navbar-collapse">
            <p>华软网络技术系毕业管理系统</p>
        </div>
        <a href="a-cookie.php?cookie=out" id="out">退出</a>
    </div>

</nav>

<div class="nav topx navbackground-a" id="nav">
    <div>

        <div style="border-bottom:1px solid rgba
(255,255,255,.1)"><img src="../images/mini.png"></div>
    </div>
    <ul>
        <li class="nav-item">
            <a href="a-index.php"><i class="my-icon nav-icon
icon_2"></i><span>首页</span><i class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="a-newsManage.php"><i class="my-icon nav-icon
icon_5"></i><span>开放/新闻管理</span><i
                    class="my-icon nav-more"></i></a>
        </li>


        <li class="nav-item">
            <a href="a-all.php"><i class="my-icon nav-icon
icon_6"></i><span>答辩汇总</span><i class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="#"><i class="my-icon nav-icon icon_3"></i><span>
答辩分组</span><i class="my-icon nav-more"></i></a>
            <ul>
                <li>
                    <a href="a-denfenAsign.php"><span>小组分配
</span></a>
                </li>
                <li>
                    <a href="a-denfenInterAsign.php"><span>组内分配
</span></a>
                </li>
            </ul>
        </li>
        <li class="nav-item">
            <a href="#"><i class="my-icon nav-icon icon_5"></i><span>资料管理</span><i class="my-icon nav-more"></i></a>
            <ul>
                <li>
                    <a href="a-sInfromationmange.php"><span>学生资料管理</span></a>
                </li>
                <li>
                    <a href="a-tInfromationmange.php"><span>教师资料管理</span></a>
                </li>
            </ul>
        </li>
    </ul>
</div>

<div class="indexborder">
    <div style="padding-top:10px;">
        <form action="a-groupProcess.php" method="post">


            <?php
            include '../conn.php';
            include "function.php";
            if (isset($_GET["groupId"])) {
                $groupId = $_GET["groupId"];
                $sql = "select defenPoint,groupAd,defentime,groupAdId
        from defenseteam WHERE  groupId='$groupId'";
                $result = mysqli_query($conn, $sql);
                $row = $result->fetch_assoc();
            }
            ?>


            <div class="box-inline indexdiv1 panel panel-default
auto" style="padding:10px">
                <div class="panel-heading" style="padding: 0px;color:
black;font-style:initial;">
                    <h3 class="panel-title " style="background-color:
#807345;padding: 15px;text-align: center;">答辩分组</h3>
                </div>
                <table class="fromtable">
                    <tr class="form-1">
                        <td>组编号</td>
                        <td><input type="text" id="groupId"
                                   name="groupId" style="height: 25px;" placeholder="输入组编号"
                                   value="<?= $groupId ?>"></td>
                    </tr>
                    <tr class="form-1">
                        <td> 组长</td>
                        <td><input type="text" id="groupAdName"
                                   name="groupAdName" style="height: 25px" placeholder="输入组长姓名"
                                   onblur="adCheck()" value="<?= $row['groupAd'] ?>"><span
                                id="adNameError" style="display:none;color: red">教师不存在
</span></td>
                    </tr>
                    <tr class="form-1">
                        <td>组长工号</td>
                        <td><input type="text" id="groupAdId"
                                   name="groupAdId" style="height: 25px" placeholder="输入组长工号"
                                   value="<?= $row['groupAdId'] ?>"></td>
                    </tr>
                    <tr class="form-1">
                        <td>答辩时间</td>
                        <td><input type="text" id="defenTime"
                                   name="defenTime" style="height: 25px" placeholder="输入答辩时间"
                                   value="<?= $row['defentime'] ?>"></td>
                    </tr>
                    <tr class="form-1">
                        <td>答辩地点</td>
                        <td><input type="text" id="defenPoint"
                                   name="defenPoint" style="height: 25px" placeholder="输入答辩地点"
                                   value="<?= $row['defenPoint'] ?>"></td>
                    </tr>
                    <tr class="form-1">
                        <td>教研室</td>
                        <td><select id="room" onchange="roomChange()"
                                    style="height: 25px">
                                <option value="0">请选择教研室</option>
                                <option value="1">网设与安全教研室
                                </option>
                                <option value="2">多媒体与网传教研室
                                </option>
                                <option value="3">信息工程教研室</option>
                            </select>
                        </td>
                    </tr>
                </table>
            </div>

            <!--            //选择教研室（多选框）-->
            <div class="box-inline indexdiv3 panel panel-default
auto" style="padding:10px;height:700px; margin-right: 5%;">

                <div class="panel-heading" style="padding: 0px;color:
black;font-style:initial;">
                    <h3 class="panel-title " style="background-color:
#807345;padding: 15px;text-align: center;">教师组员选择</h3>
                </div>
                <center> <div class="formtop">
                        <div style="height: 30px;"><center>
                                <div align="center" class="formleft">
                                    <p>供选教师</p>
                                    <select id="leftselect"></select>
                                </div>
                                <div align="center"  class="fromcenter">
                                    <p style="height: 10px"></p>
                                    <button id="button1"
                                            type="button"></button>
                                    <button id="button2"
                                            type="button"></button>
                                    <button id="button3"
                                            type="button"></button>
                                    <button id="button4"
                                            type="button"></button>
                                </div>
                                <div id=a lign="center" class="formright">
                                    <p>已选教师组员</p>
                                    <select id="rightselect" name="t[]">
                                        <?php
                                        addOption("teacherName", "teacherId","teacher",$groupId, $conn);
                                        ?>
                                    </select>
                                </div></center>
                        </div>
                    </div></center>

                <div style="height: 30px;clear: both"></div>
            </div>


            <div class="box-inline indexdiv3 panel panel-default
auto"  style="padding:10px;height:700px ">

                <div class="panel-heading" style="padding: 0px;color:
black;font-style:initial;">
                    <h3 class="panel-title " style="background-color:
#807345;padding: 15px;text-align: center;">学生组员选择</h3>
                </div>
                <div class="formtop1">
                    <div style="height: 30px;"><center>
                            <div id="leftdiv" align="center"
                                 class="formleft">
                                <p style="margin: 0px">供选学生</p>
                                搜索<input onkeyup="spick()"
                                         id="searchTest" class="input-df">
                                <select id="leftselectS"></select>
                            </div>
                            <div id="middlediv" align="center"
                                 class="fromcenter">
                                <center><p style="height: 10px"></p>
                                    <button id="button5"
                                            type="button"></button>
                                    <button id="button6"
                                            type="button"></button>
                                    <button id="button7"
                                            type="button"></button>
                                    <button id="button8"
                                            type="button"></button></center>
                            </div>
                            <div id="rightdiv" align="center"
                                 class="formright">
                                <p>已选学生</p>
                                <select id="rightselectS" name="s[]">
                                    <?php
                                    addOption("studentName", "studentId", "student",$groupId, $conn);
                                    ?>
                                </select>
                            </div></center>
                    </div>
                </div>
            </div>

            <div style="height: 20px;clear: both"></div>
            <input style="margin-left:45%;width: 100px;height: 40px"
                   type="submit" value="修改" name="actionType" id="actionType"
                   onclick="allPost()">



        </form>
    </div>
</div>




</body>
</html>